package com.demo.hxs.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.demo.hxs.entity.OrderTable;
import com.demo.hxs.service.OrderTableService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class OrderTableController {

    Page<OrderTable> page=new Page<>(1,500);

    @Resource
    private OrderTableService orderTableService;

    @GetMapping("/selectAll")
    public List<OrderTable> selectAll(){
        return orderTableService.selectAll();
    }

    @GetMapping("/selectPage")
    public Object selectPage(){
        return orderTableService.selectPage(page);
    }

    @GetMapping("costTime")
    public Object costTime(){
        long start = System.currentTimeMillis();
        IPage<OrderTable> orderTableIPage = orderTableService.selectPage(page);
        long end = System.currentTimeMillis();
        System.out.println("查询接口耗时："+(end-start)+"ms");
        return orderTableIPage;
    }

    @GetMapping("/jiekouCost")
    public String jiekouCost(){
        orderTableService.simpleWrite();
        return "全表查询数据并且插入excel接口耗时查询成功";

    }

    @GetMapping("/selectAllCost")
    public List<OrderTable> selectAllCost(){
        long start = System.currentTimeMillis();
        orderTableService.selectAll();
        long end=System.currentTimeMillis();
        System.out.println("查询orders.xlsx全量数据耗时："+(end-start)+"ms");
        return orderTableService.selectAll();
    }

}
